var wxCharts = require("../../../utils/wxcharts-min.js")
var commonUtil = require("../../../utils/commonUtil.js")
var globalData = getApp().globalData;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: globalData.imgUrl,
    vehicleNo:"",
    list:[],
    count:0,
    score:0,
    price:0,
  },
  loadInfo: function(){
    commonUtil.showLoading("加载中...");
    this.setData({ vehicleNo: wx.getStorageSync(globalData.carNoKey)});
    var list = wx.getStorageSync(globalData.peccancySelectResultKey);
    console.info(list);
    this.setData({list: list});
    if (list != null && list.length > 0) {
      let score = 0;
      let price = 0;
      for (let i = 0; i < list.length; i++) {
        if (list[i].score != null) {
          score = score + Number(list[i].score);
        }
        if (list[i].price != null) {
          price = price + Number(list[i].price);
        }
      }
      this.setData({ count: list.length });
      this.setData({ score: score });
      this.setData({ price: price });
    }
    commonUtil.hideLoading();
  },
  gohomepage: function () {
    wx.switchTab({
      url: '../homepage/homepage',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.loadInfo();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})